import java.io.*;

public abstract class Player
{
	public void zamien_karty(Card do_wyslania, ObjectOutputStream oos, ObjectInputStream ois)//, PrintWriter pb)
	{
		try
		{
			oos.writeObject("change");
			oos.writeObject(do_wyslania);
			odbierz_komunikat(ois);
		}
		catch (IOException e)
		{
			System.out.println(e.getMessage());
		}
	}
	
	public void odbierz_komunikat(ObjectInputStream ois)
	{
		try
		{
			System.out.println((String) ois.readObject());
		} 
		catch (ClassNotFoundException e)
		{
			System.out.println(e.getMessage());
		} 
		catch (IOException e)
		{
			System.out.println(e.getMessage());
		}
	}
	
	public void sprawdz(Card do_wyslania[], ObjectOutputStream oos)//, PrintWriter pb)
	{
		try
		{
			oos.writeObject("check");
			for (int i = 0; i < 5; ++i)
			{
				oos.writeObject(do_wyslania[i]);
				do_wyslania[i] = null;
			}
		}
		catch (IOException ioe)
		{
			System.out.println(ioe.getMessage());
		}
	}
	
	public void odbierz_karty(Card karty[], ObjectInputStream ois)
	{	
		for (int i = 0; i < 5; ++i)
			karty[i] = odbierz_karte(ois);
	}
	
	public Card odbierz_karte(ObjectInputStream ois)
	{
		Card temp = null;
		try
		{
			temp = (Card) ois.readObject();
		} 
		catch (ClassNotFoundException e)
		{
			System.out.println(e.getMessage());
		} 
		catch (IOException e)
		{
			System.out.println(e.getMessage());
		}
		
		return temp;
	}
	
	public void wyswietl_karty(Card karty[])
	{
		for (int i = 0; i < 5; ++i)
			System.out.println(" Indeks: " + i
					+ " Wartosc: " + karty[i].pokaz_wartosc()
					+ " znak " + karty[i].pokaz_znak());
	}
}